/*
 * @(#)SpringBeanFactory.java May 8, 2007
 * 
 * Copyright 2007 by ChinanetCenter Corporation.
 *
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * ChinanetCenter Corporation ("Confidential Information").  You
 * shall not disclose such Confidential Information and shall use
 * it only in accordance with the terms of the license agreement
 * you entered into with ChinanetCenter.
 * 
 */
package com.cnc.bas.util;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.access.BeanFactoryLocator;
import org.springframework.beans.factory.access.BeanFactoryReference;
import org.springframework.beans.factory.access.SingletonBeanFactoryLocator;





/**
 * @author ����
 * @date   May 8, 2007
 * @version 1.0
 */
public class SpringBeanFactory {
private static BeanFactory bf = null;
	
	private static Log log = Log.getLogger(SpringBeanFactory.class);

	static {
		
		String beanRefFactoryFile =  "beanRefFactory.xml";
		String groupBeanId = "SpringBeanContext";

		try {
			BeanFactoryLocator bfl = SingletonBeanFactoryLocator
					.getInstance(beanRefFactoryFile);
			BeanFactoryReference bfr = bfl.useBeanFactory(groupBeanId);
			bf = bfr.getFactory();
			 
		} catch (Throwable e) {
			 throw new RuntimeException("SpringBeanFactory exception:" + e.getMessage(), e);
		}
	}

	/**
	 * ���beanIdȡ��ʵ��
	 * 
	 * @param beanId
	 * @return
	 */

	public static Object getBean(String beanId) {
		return bf.getBean(beanId);

	}
}


